home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gamers Delight 2
/
Gamers Delight 2.iso
/
Aminet
/
game
/
gag
/
Spew.lha
/
Spew
/
manual
< prev
next >
Wrap
Text File
|
1987-04-24
|
5KB
|
158 lines
INPUT FILE FORMAT:
The file is a series of class definitions followed by an end
marker. The end marker is a line containing only "%%".
A class definition begins with a line containing '%' followed by a class
name. Class names can be any length and can consist of any combination
of upper and lower case letters, and numbers.
The lines following are instances of the class, one per line. When a
class is invoked, one of these is picked at random. Most characters in
the line are just copied to the output. The newline at the end is not
copied. An instance may be continued onto the next line by ending the
line with '\'. There is a limit of 1000 bytes on the total size of an
instance. An instance may begin with '%' if it is escaped: '\%'. A
newline may be written as '\!'. A backslash may be written as '\\'.
The following is a simple rules-file that prints out either 'foo'
or bar, followed by a carriage-return:
%MAIN
foo\!
bar\!
%%
The program generates a random instance of the class 'MAIN', which in
this case selects 'foo' or 'bar', with a 50-50 chance. A newline is
appended.
WEIGHTS
To give 'foo' a 90% chance of happening, you can assign weights:
%MAIN
(9)foo\!
bar\!
%%
The weight of 'bar' is 1 by default. If an instance is to begin with '('
it must be escaped, or given an explicit weight:
\(animal)
(1)(vegetable)
INVOCATION
Classes are normally invoked by writing their name immediately after a
backslash. Below is a rules-file which is equivalent to the foo-bar
example:
%MAIN
\word\!
%word
(9)foo
bar
%%
In this case, the class 'word' outputs either 'foo' or 'bar', and
the newline is appended after the invocation in 'MAIN'.
If you wish to immediately follow a class invokation by a letter or a number,
you must write it followed by a slash and a space:
%MAIN
\word/ bar\!
%word
foo
bar
%%
The above outputs either 'foobar' or 'barbar'. This method must also
be used if the invokation is to be immediately followed by a slash.
VARIANTS
A class may be defined with variants, and may then be invoked with
variants. The 's' variant defined for the 'fruit' class below
allows correct plurals to be generated:
%fruit{s}
apple{|s}
cherr{y|ies}
pear{|s}
mango{|es}
%MAIN
One \fruit and two \fruit/s.\!
%%
The variant tag is a single letter or number. In an invocation, the
class name is followed by a slash which is followed by the tag. Every
class has a 'null' variant (tagged by a space) by default (thus the "/ "
notation).
In the class definition line, the class name is followed by a list
of variant tags in curly brackets. The order of the tags is
significant.
In an instance definition, variants may be created with the following
notation:
{ <null-variant-text> | <1st-variant-text> | <2nd-variant-text }
When a class is invoked with a null tag, or with a blank tag, the
text before the first '|' is used. If the first tag is used in the
invocation (i.e. the first tag listed in {}'s in the class definition),
the text between the first and second |'s is used, and so forth. All
text not in {}'s is copied regardless of the tag used.
There are normally as many |'s in these as there are tags defined.
If there are too many tags, the excess ones select null strings, and
if there are too many |'s, the excess strings are redundant.
The '{' character, if required literally, must always be escaped
outside the selector construction: '\{', even when no variants are
defined in a class. The '|' and '}' characters must likewise be
escaped inside a constructor.
Invocations may appear in a selector, but cannot span a selector.
I.e. you cannot select between invoking 'catwalk' and 'catfish' by
\cat{walk|fish}
You must use {\catwalk|\catfish}.
Finally, there is the & tag which may be used in an invocation and
selects the same tag letter (or number) which the invoking
class was invoked with:
%food{s}
\fruit/& <--- this is the same as
{\fruit|\fruit/s} <--- this.
MAIN is initially invoked with the null tag (although it can be invoked
recursively with other tags).
Here is a class with multiple tags that generates irregular verbs:
%verb{sd}
{eat|eats|ate}
{be|is|was}
{see|sees|saw}
look{|s|ed}
f{ind|inds|ound}
%%
Thus \verb/d generates a past-tense verb.
COMMENTS:
At any point, '\*' may appear on a line and the rest of the line
is ignored. Blank lines are ignored completely ( as are lines
beginning in \* ).
Empty instances must therefore be given an explicit weight of one:
%AllOrNothing\* 50% chance, 'All', or nothing.
All
(1)